home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / bitstrg.zip / LINVERTB.C < prev    next >
C/C++ Source or Header  |  1989-06-01  |  619b  |  33 lines

  1. /*
  2.     librairie : bitstrg
  3.  
  4.     invertbit --    inversion de l'etat d'un bit
  5.  
  6.                 Le parametre nombre de bits est de type unsigned long
  7.  
  8.     Attention : en Small Memory Model le champ Data est limite a 64Koctets
  9. */
  10.  
  11. #include "bitstrg.h"
  12.  
  13. /*
  14.     invert state of specified bit
  15.  
  16.     if bit > map size, 0 is returned, else 1 is returned
  17. */
  18.  
  19. unsigned linvertbit(ptr,bit)
  20.     struct LSPARRAY * ptr;        /* pointer on structure */
  21.     unsigned long    bit;        /* bit number */
  22. {
  23.  
  24.     if(ptr->numlbit < bit) {
  25.         return(0);
  26.     }
  27.  
  28.         /* XOR original with 1 */
  29.  
  30.     (ptr->pntarray)[bit / SIZE] ^= (1 << (bit & (SIZE - 1)));    
  31.     return(1);
  32. }
  33.